#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
long long a[N];
int m, n;
int find(long long x)
{
    int left = 1;
    int right = m;
    while (left < right)
    {
        int mid = (right + left) / 2;
        if (a[mid] >= x)
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
    return left;
}
int main()
{
    cin >> m >> n;
    for (int i = 1; i <= m; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + m + 1);
    a[0] = -1e7 + 10;
    long long ret = 0;
    for (int i = 1; i <= n; i++)
    {
        long long x;
        cin >> x;
        int pos = find(x);
        ret += min(abs(a[pos] - x), abs(a[pos - 1] - x));
    }
    cout << ret << endl;
    return 0;
}